package com.qiaofang.applet.service.property.service.impl;

import com.qiaofang.applet.common.base.MongoBaseService;
import com.qiaofang.applet.common.context.QfContextHolder;
import com.qiaofang.applet.service.property.domain.PropertyVr;
import com.qiaofang.applet.service.property.repository.PropertyVrRepository;
import com.qiaofang.applet.service.property.service.PropertyVrService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class PropertyVrServiceImpl extends MongoBaseService<PropertyVr, String> implements PropertyVrService {

    private final PropertyVrRepository repository;

    public PropertyVrServiceImpl(PropertyVrRepository repository) {
        super(repository);
        this.repository = repository;
    }

    @Override
    public PropertyVr findByVrIdAndPropertyUuidAndCompanyUuid(Long vrId, String propertyUuid, String companyUuid) {
        return repository.findByVrIdAndPropertyUuidAndCompanyUuid(vrId, propertyUuid, companyUuid);
    }

    @Override
    public PropertyVr findByVrUuidAndPropertyUuidAndCompanyUuid(String vrUuid, String propertyUuid, String companyUuid) {
        return repository.findByVrUuidAndPropertyUuidAndCompanyUuid(vrUuid, propertyUuid, companyUuid);
    }

    @Override
    public PropertyVr findByPropertyUuidAndCityCode(String propertyUuid, String cityCode) {
        return repository.findFirstByPropertyUuidAndCityCodeAndCorporationCode(propertyUuid, cityCode, QfContextHolder.getContext().getCorporationCode());
    }
}
